<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>梦中PHP管理后台--DreamPHP系列</title>
    <link rel="shortcut icon" type="image/x-icon" href="img/logo.jpg" />
    <link rel="stylesheet" href="/static/admin/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/static/admin/css/main.css" />
</head>
<body>
<div class="container form">
    <h1 class="title">登录<small>梦中PHP后台</small></h1>
    <form action="#">
        <div class="form-group">
            <label for="username" class="control-label">用户名</label>
            <input type="text" class="form-control" id="username" name="username" placeholder="用户名" />
        </div>
        <div class="form-group">
            <label for="password" class="control-label">密码</label>
            <input type="password" class="form-control" id="password" name="password" placeholder="密码" />
        </div>
        <div class="form-group">
            <label for="verify" class="control-label">验证码</label>
            <div class="input-group">
                <input type="text" class="form-control" id="verify" name="verify" placeholder="验证码" />
                <span class="input-group-addon"><img src="{:captcha_src()}" alt="验证码" onclick="this.src='{:captcha_src()}'"></span>
            </div>
        </div>
        <div class="form-group">
            <button class="btn btn-primary btn-block" id="login">登录</button>
        </div>
    </form>
</div>

<div class="footer">
    <p>Copyright 2018 http://www.dreamphp.com.cn/ All Rights Reserved</p>
</div>

<script src="/static/admin/js/jquery-3.3.1.min.js"></script>
<script src="/static/admin/js/bootstrap.min.js"></script>
<script src="/static/lib/layer/layer.js"></script>
<script>
    $('#login').click(function () {
        $.ajax({
            url:"{:url('admin/index/index')}",
            type:'post',
            data:$('form').serialize(),
            dataType:'json',
            success:function (data) {
                if (data.code == 1) {
                    layer.msg(data.msg, {
                        icon:6,
                        time:2000
                    }, function () {
                        location.href = data.url;
                    });
                }else {
                    layer.open({
                        title:'登录失败',
                        content:data.msg,
                        skin:'layui-layer-lan',
                        icon:5,
                        anim:6
                    });
                }
            }
        });
        return false;
    });
</script>
</body>
</html>